#!/usr/bin/env python
# -*- coding:utf-8 -*- 
# Author: Jeokayne Ataier

import socket
import json

client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

client.connect(("127.0.0.1",8881))
welcome_msg = client.recv(1024).decode("utf-8")
while True:
    print(welcome_msg)
    usr = input("请输入账号：")
    pwd = input("请输入密码：")
    if not pwd:
        continue
    if not usr:
        continue
    data = {"usr":usr,"pwd":pwd}
    data_str = json.dumps(data)
    # print(data_str)
    client.sendall(data_str.encode("utf-8"))

    echo_info = client.recv(1024).decode("utf-8")

    recv_info = json.loads(echo_info)
    if recv_info["status"]:
        print(recv_info["msg"])
        break
    else:
        print(recv_info["msg"])
client.close()









